
<%--
    Document   : oEstrategico
    Created on : 10/04/2010, 03:05:56 PM
    Author     : LAPTOP01
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib uri="http://struts.apache.org/tags-bean"  prefix="bean"%>
<%@taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@ taglib uri="/tags/c" prefix="c"%>
<%@ include file="seguridad.jsp" %>
<%@ include file="acceso.jsp" %>



<html>
    <script LANGUAGE="JavaScript">
        
        function cambiarPPTO(){
            var id = document.getElementById("codMetaAPer").value;
            var ppto=document.getElementById("presuActPer").value;
            var proc=1;
            var idDiv = "divTabla";
            var metodo = "GET";
            var url = "consultasAjax/listarActMetAjax.jsp?id="+id+"&ppto="+ppto+"&proc="+proc;
            var cadenaSalida = "";
            var async = true;
            document.getElementById(idDiv).innerHTML;
            autoCompletarDiv(metodo,url,cadenaSalida,async,idDiv);

        }
        function comboOEspecifico(){
            
            var id = document.getElementById("codObj").value;
     
            var idDiv = "comboOESpecifico";
            var metodo = "GET";
            var url = "consultasAjax/comboOEspecificoAjax.jsp?id="+id;
            var cadenaSalida = "";
            var async = true;
            document.getElementById(idDiv).innerHTML;
            autoCompletarDiv(metodo,url,cadenaSalida,async,idDiv);
            //  var capa1= document.getElementById("divTabla");
            //  capa1.innerHTML="";
        }

        function comboAPermanente(){

            var id = document.getElementById("codObjEsp").value;

            var idDiv = "comboAPermanente";
            var metodo = "GET";
            var url = "consultasAjax/comboAPermanenteAjax.jsp?id="+id;
            var cadenaSalida = "";
            var async = true;
            document.getElementById(idDiv).innerHTML;
            autoCompletarDiv(metodo,url,cadenaSalida,async,idDiv);
            //   var capa1= document.getElementById("divTabla");
            //   capa1.innerHTML="";
        }

        function  mostrarAPermanente(){
            var man=1;
            //   var id = document.getElementById("codMetaAPer").value;
            var id = 1;
            var idDiv = "divTabla";
            var metodo = "GET";
            var url = "consultasAjax/listarActMetAjax.jsp?id="+id+"&man="+man+"&proc="+0;
            var cadenaSalida = "";
            var async = true;
            document.getElementById(idDiv).innerHTML;
            autoCompletarDiv(metodo,url,cadenaSalida,async,idDiv);

        }


        function editar(desc,cod){
            var form = document.getElementById("PEIForm");
            document.getElementById("opcionObj").value=2;
            document.getElementById("descObj").value=desc;
            form.codObj.value = cod;
        }

        function eliminar(codigo){
            var desc = document.getElementById("descObj").value;
            var idDiv = "divTabla";
            var metodo = "GET";
            var tipo = 3;
            var url = "consultasAjax/listarObjetivosAjax.jsp?desc="+desc+"&codigo="+codigo+"&tipo="+tipo;
            var cadenaSalida = "";
            var async = true;
            document.getElementById(idDiv).innerHTML;
            autoCompletarDiv(metodo,url,cadenaSalida,async,idDiv);
        }
        function insertar(){
            var tipo=document.getElementById("opcionObj").value;
            var codigo = document.getElementById("codObj").value;
            var desc = document.getElementById("descObj").value;

            var idDiv = "divTabla";
            var metodo = "GET";
            var url = "consultasAjax/listarObjetivosAjax.jsp?desc="+desc+"&codigo="+codigo+"&tipo="+tipo;
            var cadenaSalida = "";
            var async = true;
            document.getElementById(idDiv).innerHTML;
            autoCompletarDiv(metodo,url,cadenaSalida,async,idDiv);
            document.getElementById("opcionObj").value=1;

        }

        function autoCompletarDiv(metodo,url,cadena,async,idDiv)
        {
            if( window.XMLHttpRequest )
                ajax = new XMLHttpRequest(); // No Internet Explorer
            else
                ajax = new ActiveXObject("Microsoft.XMLHTTP");
            ELEMENT_DIV = idDiv;
            ajax.onreadystatechange = funcionCallbackVerDiv;
            ajax.open( metodo, url, async);
            ajax.send(cadena);
        }

        function funcionCallbackVerDiv()
        {
            if( ajax.readyState == 4 )
            {
                if( ajax.status == 200 )
                { //alert(ajax.responseText);
                    document.getElementById(ELEMENT_DIV).innerHTML = ajax.responseText;
                }
            }
        }

function agregarCantTpoUni(){
    var c=document.getElementById("codMetaAPer").value;
    document.getElementById("agregarCantTpoUni").style.display='';
    
    //alert(c);

}
    </script>

    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" href="lib/css/estilos.css" type="text/css">
        <link href="lib/css/styles_pages.css" rel="stylesheet" type="text/css" />
        <title>JSP Page</title>
    </head>
    <body  onload="mostrarAPermanente()">
        <center>
            <h1>Demanda1</h1>
            <table>
                <tr>
                    <td width="300">
                        <html:form action="PEI.do?dispatch=ingresarOEstrategico" styleId="PEIForm"  >
                            <html:hidden property="opcionObj" styleId="opcionObj" value="1"/>
                            <fieldset>
                                <legend>Ingresar</legend>
                                <html:select property='codObj' styleId='codObj' onchange='comboOEspecifico()'>
                                    <html:option value='-1'>[--Seleccionar Objetivo Estrat&eacute;gico--]</html:option>
                                    <html:optionsCollection name='PEIForm' property='listaOEstrategico' value='NUM_CODOBJ_PK' label='TX_DESCOBJ' />
                                </html:select>
                                <br><br>
                                <div id="comboOESpecifico">
                                    <html:select property="codObjEsp" styleId="codObjEsp" >
                                        <html:option value="-1">[--Seleccionar Obj Especifico--]</html:option>
                                        <html:optionsCollection name="PEIForm" property="listaOEspecifico" value="NUM_CODOBJESP_PK" label="TX_DESCOBJESP" />
                                    </html:select>
                                </div>
                                <br>

                                <div id="comboAPermanente">
                                    <html:select property="codMetaAPer" styleId="codMetaAPer" onclick='agregarCantTpoUni();'>
                                        <html:option value="-1">[--Seleccionar Act Permanente--]</html:option>
                                        <html:optionsCollection name="PEIForm" property="listaActPer" value="NUM_CODACTPER_PK" label="TX_DESCACTPER" />
                                        <html:option value="0">Nueva Actividad Permanente</html:option>
                                    </html:select>
                                </div>
                                <br>
                                <img style="cursor:pointer" title="Edit" title="Edit" alt="Edit" border=0
                                     src="images/b_edit.png" onclick="agregarCantTpoUni();">
                                <br>
                                PPTO :<html:text property="presuActPer" styleId="presuActPer"/>

                                <br>
                                <input type="button" value="Grabar" onclick="cambiarPPTO()"/>

                            </fieldset>
                            <br><br>

                            <div id="divTabla">

                            </div>

                            <div id="agregarCantTpoUni" style="display:none">

                                <table>
                                    <tr>
                                        <td>
                                         UM
                                        </td>
                                        <td>
                                            <input type="text" id="unidadMedida"  />
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            Cantidad
                                        </td>
                                        <td>
                                            <input type="text" id="cantidad"  />
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            Tipo
                                        </td>
                                        <td>
                                            <input type="text" id="tipo"  />
                                        </td>
                                    </tr>
                                </table>

                                <div id="listCantTpoUni">

                                    
                                </div>

                            </div>

                        </html:form>
                    </td>
                </tr>
            </table>
        </center>
    </body>
</html>